<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>指定 addrinfo 创建并连接套接字</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.socket-addrinfo-bind.html">« socket_addrinfo_bind</a></li>
      <li style="float: right;"><a href="function.socket-addrinfo-explain.html">socket_addrinfo_explain »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.sockets.html">Socket 函数</a></li>
    <li>指定 addrinfo 创建并连接套接字</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.socket-addrinfo-connect" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">socket_addrinfo_connect</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.2.0, PHP 8)</p><p class="refpurpose"><span class="refname">socket_addrinfo_connect</span> &mdash; <span class="dc-title">指定 addrinfo 创建并连接套接字</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.socket-addrinfo-connect-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>socket_addrinfo_connect</strong></span>(<span class="methodparam"><span class="type"><a href="class.addressinfo.html" class="type AddressInfo">AddressInfo</a></span> <code class="parameter">$address</code></span>): <span class="type"><span class="type"><a href="class.socket.html" class="type Socket">Socket</a></span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   创建 <span class="classname"><a href="class.socket.html" class="classname">Socket</a></span> 实例，并连接到 <span class="classname"><a href="class.addressinfo.html" class="classname">AddressInfo</a></span> 实例。此函数的返回值可以和其余套接字函数一起使用。
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.socket-addrinfo-connect-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">address</code></dt>

    <dd>

     <p class="para">
      从 <span class="function"><a href="function.socket-addrinfo-lookup.html" class="function">socket_addrinfo_lookup()</a></span> 创建的 <span class="classname"><a href="class.addressinfo.html" class="classname">AddressInfo</a></span> 实例。
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.socket-addrinfo-connect-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <span class="classname"><a href="class.socket.html" class="classname">Socket</a></span> 实例，失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.socket-addrinfo-connect-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       现在该函数成功时返回 <span class="classname"><a href="class.socket.html" class="classname">Socket</a></span> 实例；在此之前，返回值是 <span class="type">resource</span>。
      </td>
     </tr>

     <tr>
 <td>8.0.0</td>
 <td>
  现在 <code class="parameter">address</code> 是 <span class="classname"><a href="class.addressinfo.html" class="classname">AddressInfo</a></span> 实例，
  之前是 <span class="type">resource</span>。
 </td>
</tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.socket-addrinfo-connect-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.socket-addrinfo-bind.html" class="function" rel="rdfs-seeAlso">socket_addrinfo_bind()</a> - 从给定的 addrinfo 创建并绑定一个套接字</span></li>
    <li class="member"><span class="function"><a href="function.socket-addrinfo-explain.html" class="function" rel="rdfs-seeAlso">socket_addrinfo_explain()</a> - 获取有关 addrinfo 的信息</span></li>
    <li class="member"><span class="function"><a href="function.socket-addrinfo-lookup.html" class="function" rel="rdfs-seeAlso">socket_addrinfo_lookup()</a> - 获取数组，包含有关给定主机名的 getaddrinfo 内容</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>